<form id="frm_add" method="post" accept-charset="utf-8" action="<?php print $active; ?>">
<div>
    <table style="margin: auto;">
        <tbody>
            <tr>
                <td><label for="username"><?php print lang('user_username'); ?></label></td>
                <td><input type="text" name="username" value="<?php print ( isset($user) )? $user->username : ''; ?>" class="itext ivalidate ui-widget-content ui-corner-all" /></td>
            </tr>
            <tr>
                <td colspan="2"><div id="error_username" class="error"></div></td>
            </tr>
            <tr>
                <td><label for="full_name"><?php print lang('user_fullname'); ?></label></td>
                <td><input type="text" name="full_name" value="<?php print ( isset($user) )? $user->full_name : ''; ?>" class="itext ivalidate ui-widget-content ui-corner-all" /></td>
            </tr>
            <tr>
                <td colspan="2"><div id="error_full_name" class="error"></div></td>
            </tr>
            <tr>
                <td><label for="password"><?php print lang('user_password'); ?></label></td>
                <td><input type="password" name="password" value="" class="itext ivalidate ui-widget-content ui-corner-all" /></td>
            </tr>
            <tr>
                <td colspan="2"><div id="error_password" class="error"></div></td>
            </tr>
            <tr>
                <td><label for="repassword"><?php print lang('user_repassword'); ?></label></td>
                <td><input type="password" name="repassword" value="" class="itext ivalidate ui-widget-content ui-corner-all" /></td>
            </tr>
            <tr>
                <td><label for="email"><?php print lang('user_email'); ?></label></td>
                <td><input type="text" name="email" value="<?php print ( isset($user) )? $user->email : ''; ?>" class="itext ivalidate ui-widget-content ui-corner-all" /></td>
            </tr>
            <tr>
                <td colspan="2"><div id="error_email" class="error"></div></td>
            </tr>
            <tr>
                <td><label for="name"><?php print lang('user_role'); ?></label></td>
                <td>
                    <select name="role_id" class="itext ui-widget-content ui-corner-all">
                    
                        <?php foreach($roles As $role): ?>
                            <option value="<?php print $role->role_id; ?>" <?php 
                            if($act == 'add'){
                                if($role->default == 1){
                                    print 'selected="selected"';
                                }
                            }else{
                                if($role->role_id == $user->role_id){
                                    print 'selected="selected"';
                                }
                            }
                            //print ( $role->default == 1 ) ? 'selected="selected"':''; ?>><?php print $role->role_name; ?></option>
                        <?php endforeach; ?>
                    
                    </select>
                </td>
            </tr>
            <tr>
                <td><label for="status"><?php print lang('user_status'); ?></label></td>
                <td>
                    <select name="status" class="itext ui-widget-content ui-corner-all">
                        <option value="1" <?php print ( isset($user) && $user->status == 1 ) ? 'selected="selected"':''; ?>><?php print lang('user_tt_active'); ?></option>
                        <option value="2" <?php print ( isset($user) && $user->status == 2 ) ? 'selected="selected"':''; ?>><?php print lang('user_tt_disable'); ?></option>
                        <?php if( isset($user) && $user->status == -1 ): ?>
                        <option value="-1" <?php print ( isset($user) && $user->status == -1 ) ? 'selected="selected"':''; ?>><?php print lang('user_tt_delete'); ?></option>
                        <?php endif; ?>
                    </select>
                </td>
            </tr>
        </tbody>
    </table>
    <?php if( isset($user) ): ?>
    <input type="hidden" name="id" value="<?php print $user->id; ?>">
    <?php endif; ?>
</div>
</form>